Skip to main content

RSpec

In the steps below, we'll start with a Ruby project that has an existing RSpec test suite, and we'll add JUnit XML as an additional output format for the test suite. In each step, we'll show the Git diff for the change that we're making.

  1. Add rspec_junit_formatter as a dependency.

    bundle add rspec_junit_formatter

    Verify that your Gemfile file includes the new dependency:

     source 'https://rubygems.org'
    ruby '2.6.6'

    gem 'rspec'
    +gem 'rspec_junit_formatter'
  2. Update your .rspec configuration file to output JUnit XML reports at spec/reports/rspec.xml.

     --require spec_helper
    --format progress
    +--format RspecJunitFormatter
    +--out spec/reports/rspec.xml
  3. Update your .gitignore file so that the JUnit report doesn't accidentally get checked into the repository.

     /.bundle
    +/spec/reports
  4. Commit these changes to your repository.

    git commit -am "Generate test reports with rspec_junit_formatter"

    The final result of these changes should resemble commit 4c1403c in the buildpulse-example-rspec repository.